<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http:dream/cust_tag.tld" prefix="page"%>
<script type="text/javascript">
function modifyItem( index ){

	$("#name"+index).removeAttr("disabled");
	$("#save"+index).removeClass("hide");
	$("#modify"+index).addClass("hide");
	return false;
	
}
function updateSucc(){
	common.closeYesNoDialog();
	reloadTree($("#parentId").val());
	reloadChildren($("#parentId").val());
}


function saveItem(parentId,id,name){
	
	var name = $.trim($(name).val());
	if(common.isEmpty(name)){
		alert("请输入分类名称!");
		return;
	}
	 var param={};
	 if(id){
		 param.id = id;
	 }
	 param.parentId = parentId;
	 param.name = name;

	 var uri = updUri();
	 common.ajaxSubmitWithData(uri,param,"保存分类失败","",'updateSucc()');
	 
}
function delItem(id){
	
	if(confirm("确定删除分类!")){
		 var uri = delUri()+id
		 common.ajaxSubmitWithData(uri,{},"删除分类失败","",'updateSucc()');
	}
	 
}

</script>
<input type="hidden" value="${parent.id }" id="parentId">
<div class="widget-box">
    <div class="widget-title"> <span class="icon"> <i class="icon-list"></i> </span>
      <h5><code><c:out value="${parent.name }"></c:out></code></h5>
	</div>
	
<div class="widget-content"> 
 <table class="table table-bordered table-striped">
	<tr >
		<th class="span1 text-center">序号</th>
		<th class="span2 text-center">编号</th>
		<th class="span6 text-center">名称</th>
		<th class="span3 text-center">操作</th>
	</tr>
	<c:forEach var="vo" varStatus="vs" items="${parent.children}">
	<tr id="item${vs.count}">
		<td class="text-center">
			<c:out value="${vs.count}"/>
		</td>
		<td class="text-center">
			<c:out value="${vo.id}"/>
		</td>
		<td class="text-left controls" >
			 <input type="text" class="input-xlarge"  maxlength="50" id="name${vs.count}"  value="${vo.name }" disabled >
		</td>
		<td class="text-center">
			<a id="save${vs.count}" class="btn btn-success hide" href='javascript:void(0)' onclick="saveItem('${parent.id }','${vo.id}','#name${vs.count}')" >
				保存
			</a>
			<a id="modify${vs.count}" class="btn btn-warning" href='javascript:void(0)' onclick="modifyItem('${vs.count}')" >
				修改
			</a>
			&nbsp;&nbsp;
			<a class="btn btn-danger"href='javascript:void(0)' onclick="delItem('${vo.id}')"  >
				删除
			</a>
		</td>
	</tr>
</c:forEach>
	<tr >
		<td class="text-center"></td>
		<td class="text-center"></td>
		<td class="text-left controls">
			<input type="text" class="input-xlarge"  maxlength="50" name="name" id="new_name"  >
		</td>
		<td class="text-center">
			<a  class="btn btn-success" href='javascript:void(0)' onclick="saveItem('${parent.id }','','#new_name')" >
				增加
			</a>
		</td>
	</tr>
</table>
</div>
</div>


 		


